/*
* INSANE - Interactive Structural Analysis Environment
*
* Copyright (C) 2003-2005
* Universidade Federal de Minas Gerais
* Escola de Engenharia
* Departamento de Engenharia de Estruturas
* 
* Author's email :    insane@dees.ufmg.br
* Author's website :  http://www.dees.ufmg.br/insane
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package br.ufmg.dees.insane.ui.rich.learn.learn_view.model_view.command;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import br.ufmg.dees.insane.ui.rich.learn.learn_view.dialog.MatrixViewTableDialog;

/**
*
* @author Moreira, Renata & Pitangueira, Roque
* @since May 2005
*/
public class ModelFrame extends JFrame{
	
	private static final long serialVersionUID = 1L;
	private ModelPanel mp1;
	
	
	public ModelFrame(int o, MatrixViewTableDialog dlgK, String model, MatrixViewTableDialog dlg, String elm) 
	{ setTitle("INSANE");
		//	 Pega as configuracoes do usuario
	Toolkit tk=Toolkit.getDefaultToolkit();
	Dimension d = tk.getScreenSize();
	int screenHeight=d.height;
	int screenWidth=d.width;
	int frameWidth=(int)8*screenWidth/10;
	int frameHeight=(int)8*screenHeight/10;
	setSize(frameWidth,frameHeight); 
	addWindowListener(new WindowAdapter()
	    { public void windowClosing(WindowEvent e)
	    { this.windowClosed(e);
	    }
	    } );		
	// posiciona o frame no meio da tela
	setLocation(screenWidth/8,screenHeight/10);
	//Atribui um icone ao frame
	Image icone =tk.getImage("icone.jpg");
	setIconImage(icone);
	//Cria o container e atribui o layout de GridBag
	Container contentPane=getContentPane();
	mp1 = new ModelPanel(frameWidth,frameHeight, o, dlgK, model, dlg, elm);
	contentPane.add(mp1);
	}
	/*
	public ModelFrame(int o, MatrixViewTableDialog dlgK, String Kname, MatrixViewTableDialog dlgD ,
			  String Dname, MatrixViewTableDialog dlgF ,String Fname,MatrixViewTableDialog dlgP ,String Pname) 
	{ setTitle("INSANE");
		//	 Pega as configuracoes do usuario
	Toolkit tk=Toolkit.getDefaultToolkit();
	Dimension d = tk.getScreenSize();
	int screenHeight=d.height;
	int screenWidth=d.width;
	int frameWidth=(int)8*screenWidth/10;
	int frameHeight=(int)8*screenHeight/10;
	setSize(frameWidth,frameHeight); 
	addWindowListener(new WindowAdapter()
	    { public void windowClosing(WindowEvent e)
	    { this.windowClosed(e);
	    }
	    } );		
	// posiciona o frame no meio da tela
	setLocation(screenWidth/8,screenHeight/10);
	//Atribui um icone ao frame
	Image icone =tk.getImage("icone.jpg");
	setIconImage(icone);
	//Cria o container e atribui o layout de GridBag
	Container contentPane=getContentPane();
	ElmEquilibriumPanel elmMp = new ElmEquilibriumPanel(frameWidth,frameHeight,o,dlgK,Kname,dlgD,Dname,dlgF,Fname,dlgP , Pname);
	contentPane.add(elmMp);
	}*/
	
	
	
	public ModelFrame(MatrixViewTableDialog dlg, Dimension d){
		setTitle(dlg.getTitle());
		Toolkit tk=Toolkit.getDefaultToolkit();
		//Dimension d = tk.getScreenSize();
		Dimension maxD = new Dimension(800,500);
		
		if(d.width<maxD.width && d.height<maxD.height){
			int screenHeight=d.height+50;
			int screenWidth=d.width+50;
			setSize(screenWidth,screenHeight); 
			addWindowListener(new WindowAdapter()
			    { public void windowClosing(WindowEvent e)
			    { this.windowClosed(e);
			    }
			    } );		
			// posiciona o frame no meio da tela
			setLocation(screenWidth/8,screenHeight/10);
			//Atribui um icone ao frame
			Image icone =tk.getImage("icone.jpg");
			setIconImage(icone);
			JPanel panel = new JPanel();
			JScrollPane spane = new JScrollPane(dlg.getTablePane());
			spane.setPreferredSize(new Dimension(d.width,d.height));
			spane.createHorizontalScrollBar();
		 	spane.createVerticalScrollBar();
		 	spane.revalidate();
		 	spane.repaint();
		 	panel.add(spane);
			Container contentPane=getContentPane();
			contentPane.add(panel);
		}
		else{
			int screenHeight=850;
			int screenWidth=550;
			setSize(screenWidth,screenHeight); 
			addWindowListener(new WindowAdapter()
			    { public void windowClosing(WindowEvent e)
			    { this.windowClosed(e);
			    }
			    } );		
			// posiciona o frame no meio da tela
			setLocation(screenWidth/8,screenHeight/10);
			//Atribui um icone ao frame
			Image icone =tk.getImage("icone.jpg");
			setIconImage(icone);
			JPanel panel = new JPanel();
			JScrollPane spane = new JScrollPane(dlg.getTablePane());
			spane.setPreferredSize(new Dimension(800,500));
			spane.createHorizontalScrollBar();
		 	spane.createVerticalScrollBar();
		 	spane.revalidate();
		 	spane.repaint();
		 	panel.add(spane);
			Container contentPane=getContentPane();
			contentPane.add(panel);
		}
		
		
	 	
	}
	
	public ModelPanel getMenuPanel(){
		return mp1;
	}
	
	
}
